/**
 * @author Ahammer
 * @date 2009 06
 */

/*
 * This file is part of Iqm.
 * Copyright (c) 2010-2011 Helmut Ahammer
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package opgui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.NumberFormat;
import javax.media.jai.ParameterBlockJAI;
import javax.media.jai.PlanarImage;
import javax.swing.ButtonGroup;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import main.IqmTools;
import main.Tank;


public class IqmAffineGUI  extends IqmOperatorJFrame
						  implements IqmOperatorGUIBuilder, ActionListener, PropertyChangeListener {

	private  ParameterBlockJAI   pb         = null;  //  @jve:decl-index=0:
	//public  ImgProcFuncJFrame  opGUIFrame = null;
	//private  IqmAffineGUI 		 opGUIFrame = null;  //actionPerformed events werden in dieser Klasse abgehandelt
		
	private JPanel 				 	jPanelM00					= null;	
	private JLabel				 	jLabelM00					= null;
	private JFormattedTextField 	jFormattedTextFieldM00 	    = null;	
	private JPanel 				 	jPanelM10					= null;	
	private JLabel				 	jLabelM10					= null;
	private JFormattedTextField 	jFormattedTextFieldM10 		= null;	
	private JPanel 				 	jPanelM01					= null;	
	private JLabel				 	jLabelM01					= null;
	private JFormattedTextField 	jFormattedTextFieldM01 		= null;
	private JPanel 				 	jPanelM11					= null;	
	private JLabel				 	jLabelM11					= null;
	private JFormattedTextField 	jFormattedTextFieldM11 		= null;
	private JPanel 				 	jPanelM02					= null;	
	private JLabel				 	jLabelM02					= null;
	private JFormattedTextField 	jFormattedTextFieldM02 		= null;
	private JPanel 				 	jPanelM12					= null;	
	private JLabel				 	jLabelM12					= null;
	private JFormattedTextField 	jFormattedTextFieldM12 		= null;

	private  JRadioButtonMenuItem  buttNN         = null;	//nearest neighbor
	private  JRadioButtonMenuItem  buttBL         = null;	//bilinear
	private  JRadioButtonMenuItem  buttBC      	  = null;	//bicubic
	private  JRadioButtonMenuItem  buttBC2   	  = null;	//bicubic2
	private  JRadioButtonMenuItem  buttIntPHidden = null;
	private  JToolBar              jToolBarIntP   = null;
	private  ButtonGroup           buttGroupIntP  = null;
	
	/**
	 * constructor
	 */
	public IqmAffineGUI() {

	}

	
	/**
	 * This method sets all  variables to null
	 */
	private void resetVariables(){
		pb         = null; 
		//opGUIFrame = null; 	
		//jToolBarRGB  = null;
	}
	/**
	 * This method sets all parameters to null
	 */
	private void resetParameters(){
		//butt       = null;
		//butt       = null;
	}

	/**
	 * This method sets the current parameter block to the argument
	 * @param ParameterBlockJAI pb
	 */
	@Override
	public void setParameterBlock(ParameterBlockJAI arg){
		pb = arg;
		IqmTools.setCurrParameterBlockJAI(pb);	
	}
	/**
	 * This method sets the current parameter block
	 * The individual values of the GUI  current ParameterBlock
	 *
	 */
	@Override
	public void setParameterBlock(){
		pb.setParameter("M00", (float)((Number)jFormattedTextFieldM00.getValue()).floatValue());
		pb.setParameter("M10", (float)((Number)jFormattedTextFieldM10.getValue()).floatValue());
		pb.setParameter("M01", (float)((Number)jFormattedTextFieldM01.getValue()).floatValue());
		pb.setParameter("M11", (float)((Number)jFormattedTextFieldM11.getValue()).floatValue());
		pb.setParameter("M02", (float)((Number)jFormattedTextFieldM02.getValue()).floatValue());
		pb.setParameter("M12", (float)((Number)jFormattedTextFieldM12.getValue()).floatValue());
		if (buttNN.isSelected())  pb.setParameter("Interpolation", 0);
		if (buttBL.isSelected())  pb.setParameter("Interpolation", 1);
		if (buttBC.isSelected())  pb.setParameter("Interpolation", 2);
		if (buttBC2.isSelected()) pb.setParameter("Interpolation", 3);
		IqmTools.setCurrParameterBlockJAI(pb);	
	}
	
	/**
	 * This method sets the current parameter values
	 *
	 */
	@Override
	public void setParameterValues(){
		int idx = IqmTools.getCurrManagerImgIndex();
	    PlanarImage pi = Tank.getCurrentTankImageAt(idx); 
	       if (pi == null){
	    	   System.out.println("IqmAffineGUI: Current image not defined");
	    	   return;
	       }

	    jFormattedTextFieldM00.removePropertyChangeListener("value", this);	 
	    jFormattedTextFieldM10.removePropertyChangeListener("value", this);	    
	    jFormattedTextFieldM01.removePropertyChangeListener("value", this);	    	    
	    jFormattedTextFieldM11.removePropertyChangeListener("value", this);	    	    
	    jFormattedTextFieldM02.removePropertyChangeListener("value", this);	    	    
	    jFormattedTextFieldM12.removePropertyChangeListener("value", this);	    	    
	    jFormattedTextFieldM00.setValue(pb.getFloatParameter("M00"));
		jFormattedTextFieldM10.setValue(pb.getFloatParameter("M10"));
	    jFormattedTextFieldM01.setValue(pb.getFloatParameter("M01"));
	    jFormattedTextFieldM11.setValue(pb.getFloatParameter("M11"));
	    jFormattedTextFieldM02.setValue(pb.getFloatParameter("M02"));
	    jFormattedTextFieldM12.setValue(pb.getFloatParameter("M12"));
	    jFormattedTextFieldM00.addPropertyChangeListener("value", this);
	    jFormattedTextFieldM10.addPropertyChangeListener("value", this);
	    jFormattedTextFieldM01.addPropertyChangeListener("value", this);
	    jFormattedTextFieldM11.addPropertyChangeListener("value", this);
	    jFormattedTextFieldM02.addPropertyChangeListener("value", this);
	    jFormattedTextFieldM12.addPropertyChangeListener("value", this);
	    
		if (pb.getIntParameter("Interpolation") == 0)  buttNN.setSelected(true);
		if (pb.getIntParameter("Interpolation") == 1)  buttBL.setSelected(true);
		if (pb.getIntParameter("Interpolation") == 2)  buttBC.setSelected(true);
		if (pb.getIntParameter("Interpolation") == 3)  buttBC2.setSelected(true);

	}

	/**
	 * This method creates and shows the GUI
	 */
	@Override
	public void createIqmOperatorGUI() {
		//System.out.println("IqmAffine: createAndShowGUI invoked");
		//opGUIFrame = new IqmAffineGUI();      //actionPerforemd events werden in dieser Klasse abgehandelt
		//opGUIFrame.getJContentPane();
		this.initialize(); //Aufruf von ImgProcFuncJFrame
		this.setTitle("Affine");
		//PlanarImage pi = Tank.getCurrentTankImageAt(IqmTools.getCurrManagerImgIndex());
		//Dimension dim = this.getSize();
		//this.setSize(dim.width, dim.height+280);
		//this.setPreferredSize(new Dimension(800, 600));

		this.getJContentPane().add(getJPanelM00(), getGridBagConstraintsM00());
		this.getJContentPane().add(getJPanelM10(), getGridBagConstraintsM10());
		this.getJContentPane().add(getJPanelM01(), getGridBagConstraintsM01());
		this.getJContentPane().add(getJPanelM11(), getGridBagConstraintsM11());
		this.getJContentPane().add(getJPanelM02(), getGridBagConstraintsM02());
		this.getJContentPane().add(getJPanelM12(), getGridBagConstraintsM12());
		this.getJContentPane().add(getJToolBarIntP(),   getGridBagConstraintsButtonIntPGroup());

		this.pack();
		//this.repaint();
		if (pb == null) pb = new ParameterBlockJAI("IqmAffine");  //nur wenn das erste mal aufgerufen
		//pb = new ParameterBlockJAI("iqmthreshold"); //immer der default Block
		IqmTools.setCurrParameterBlockJAI(pb);
		this.setParameterValues();
	
	}

	private  GridBagConstraints getGridBagConstraintsM00(){
		GridBagConstraints gridBagConstraintsM00 = new GridBagConstraints();
		gridBagConstraintsM00.gridx = 1;
		gridBagConstraintsM00.gridy = 5;
		gridBagConstraintsM00.gridwidth = 1;//?
		gridBagConstraintsM00.insets = new Insets(10,0,0,0); //top left bottom right
		//gridBagConstraintsM00.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM00;
	}
	private  GridBagConstraints getGridBagConstraintsM10(){
		GridBagConstraints gridBagConstraintsM10 = new GridBagConstraints();
		gridBagConstraintsM10.gridx = 1;
		gridBagConstraintsM10.gridy = 6;
		gridBagConstraintsM10.gridwidth = 1;//?
		gridBagConstraintsM10.insets = new Insets(10,0,0,0);  //top left bottom right
		//gridBagConstraintsM10.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM10;
	}
	private  GridBagConstraints getGridBagConstraintsM01(){
		GridBagConstraints gridBagConstraintsM01 = new GridBagConstraints();
		gridBagConstraintsM01.gridx = 2;
		gridBagConstraintsM01.gridy = 5;
		gridBagConstraintsM01.gridwidth = 1;//?
		gridBagConstraintsM01.insets = new Insets(10,0,0,0);  //top left bottom right
		//gridBagConstraintsM01.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM01;
	}
	private  GridBagConstraints getGridBagConstraintsM11(){
		GridBagConstraints gridBagConstraintsM11 = new GridBagConstraints();
		gridBagConstraintsM11.gridx = 2;
		gridBagConstraintsM11.gridy = 6;
		gridBagConstraintsM11.gridwidth = 1;//?
		gridBagConstraintsM11.insets = new Insets(10,0,0,0);  //top left bottom right
		//gridBagConstraintsM11.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM11;
	}
	private  GridBagConstraints getGridBagConstraintsM02(){
		GridBagConstraints gridBagConstraintsM02 = new GridBagConstraints();
		gridBagConstraintsM02.gridx = 3;
		gridBagConstraintsM02.gridy = 5;
		gridBagConstraintsM02.gridwidth = 1;//?
		gridBagConstraintsM02.insets = new Insets(10,0,0,0);  //top left bottom right
		//gridBagConstraintsM02.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM02;
	}
	private  GridBagConstraints getGridBagConstraintsM12(){
		GridBagConstraints gridBagConstraintsM12 = new GridBagConstraints();
		gridBagConstraintsM12.gridx = 3;
		gridBagConstraintsM12.gridy = 6;
		gridBagConstraintsM12.gridwidth = 1;//?
		gridBagConstraintsM12.insets = new Insets(10,0,0,0);  //top left bottom right
		//gridBagConstraintsM12.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsM12;
	}
	private  GridBagConstraints getGridBagConstraintsButtonIntPGroup(){
		GridBagConstraints gridBagConstraintsButtonIntPGroup = new GridBagConstraints();
		gridBagConstraintsButtonIntPGroup.gridx = 2;
		gridBagConstraintsButtonIntPGroup.gridy = 7;
		gridBagConstraintsButtonIntPGroup.gridwidth = 2;//?
		gridBagConstraintsButtonIntPGroup.insets = new Insets(10,0,20,0);  //top left bottom right		
		//gridBagConstraintsButtonIntPGroup.fill = GridBagConstraints.BOTH;
		return gridBagConstraintsButtonIntPGroup;
	}
	/**
	 * This method closes and destroys the GUI
	 * 
	 * @return void
	 */
//	public void destroyGUI() {
//		if (this != null){
//					
//			//this.closeAndDestroyGUI();
//			//resetVariables();
//			//folgendes geht auch!?
//			this.setVisible(false);
//			this.dispose();
//			//this = null;
//		}
//	}
	/**
	 * This method updates the GUI
	 * This method overrides IqmOperatorJFrame
	 */
	@Override
	public void updateIqmOperatorGUI(){

	}
	//------------------------------------------------------------------------------------------------------------------
	class FloatNumberVerifier extends InputVerifier { //damit muss Eingabe richtig sein 
		@Override
		public boolean verify(JComponent input) {
		   JFormattedTextField ftf = (JFormattedTextField)input;
		   JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
		   if (formatter != null) {
		      String text = ftf.getText();
		  	  try {
				   text = text.replace(",", ".");
				   Float.valueOf(text);
					//Float.valueOf(text);
					return true;
			  } catch (NumberFormatException e) {
					return false;
			  }	 
		   }
		   return true;
		}
//		public boolean shouldYieldFocus(JComponent input) {
//		System.out.println("NumberVerifier  shouldYieldFocus");
//
//          return verify(input);
//    }
}
	/**
	 * This method initializes jJPanelM00	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM00() {
		if (jPanelM00 == null) {
			jPanelM00 = new JPanel();
			jPanelM00.setLayout(new BorderLayout());
			//jPanelM00.setPreferredSize(new Dimension(250,18));					
			jLabelM00 = new JLabel("M00:");
			jLabelM00.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM00 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM00.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM00.addPropertyChangeListener("value", this);
			jFormattedTextFieldM00.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM00.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM00.setColumns(5);
			jPanelM00.add(jLabelM00, 			  BorderLayout.WEST);
			jPanelM00.add(jFormattedTextFieldM00, BorderLayout.CENTER);	
		
		}
		return jPanelM00;
	}
	/**
	 * This method initializes jJPanelM10	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM10() {
		if (jPanelM10 == null) {
			jPanelM10 = new JPanel();
			jPanelM10.setLayout(new BorderLayout());
			//jPanelM10.setPreferredSize(new Dimension(250,18));					
			jLabelM10 = new JLabel("M10:");
			jLabelM10.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM10 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM10.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM10.addPropertyChangeListener("value", this);
			jFormattedTextFieldM10.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM10.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM10.setColumns(5);
			jPanelM10.add(jLabelM10, 			  BorderLayout.WEST);
			jPanelM10.add(jFormattedTextFieldM10, BorderLayout.CENTER);
			jFormattedTextFieldM10.setEnabled(true);	
		}
		return jPanelM10;
	}
	/**
	 * This method initializes jJPanelM01	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM01() {
		if (jPanelM01 == null) {
			jPanelM01 = new JPanel();
			jPanelM01.setLayout(new BorderLayout());
			//jPanelM01.setPreferredSize(new Dimension(250,18));					
			jLabelM01 = new JLabel("M01:");
			jLabelM01.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM01 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM01.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM01.addPropertyChangeListener("value", this);
			jFormattedTextFieldM01.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM01.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM01.setColumns(5);
			jPanelM01.add(jLabelM01, 			  BorderLayout.WEST);
			jPanelM01.add(jFormattedTextFieldM01, BorderLayout.CENTER);	
			jFormattedTextFieldM01.setEnabled(true);
		}
		return jPanelM01;
	}
	/**
	 * This method initializes jJPanelM11	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM11() {
		if (jPanelM11 == null) {
			jPanelM11 = new JPanel();
			jPanelM11.setLayout(new BorderLayout());
			//jPanelM11.setPreferredSize(new Dimension(250,18));					
			jLabelM11 = new JLabel("M11:");
			jLabelM11.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM11 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM11.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM11.addPropertyChangeListener("value", this);
			jFormattedTextFieldM11.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM11.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM11.setColumns(5);
			jPanelM11.add(jLabelM11, 			  BorderLayout.WEST);
			jPanelM11.add(jFormattedTextFieldM11, BorderLayout.CENTER);	
			jFormattedTextFieldM11.setEnabled(true);
		}
		return jPanelM11;
	}
	/**
	 * This method initializes jJPanelM02	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM02() {
		if (jPanelM02 == null) {
			jPanelM02 = new JPanel();
			jPanelM02.setLayout(new BorderLayout());
			//jPanelM02.setPreferredSize(new Dimension(250,18));					
			jLabelM02 = new JLabel("M02:");
			jLabelM02.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM02 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM02.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM02.addPropertyChangeListener("value", this);
			jFormattedTextFieldM02.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM02.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM02.setColumns(5);
			jPanelM02.add(jLabelM02, 			  BorderLayout.WEST);
			jPanelM02.add(jFormattedTextFieldM02, BorderLayout.CENTER);	
			jFormattedTextFieldM02.setEnabled(true);
		}
		return jPanelM02;
	}
	/**
	 * This method initializes jJPanelM12	
	 * 	
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanelM12() {
		if (jPanelM12 == null) {
			jPanelM12 = new JPanel();
			jPanelM12.setLayout(new BorderLayout());
			//jPanelM12.setPreferredSize(new Dimension(250,18));					
			jLabelM12 = new JLabel("M12:");
			jLabelM12.setPreferredSize(new Dimension(30,18));
			jFormattedTextFieldM12 = new JFormattedTextField(NumberFormat.getNumberInstance());
			jFormattedTextFieldM12.setPreferredSize(new Dimension(40,18));
			jFormattedTextFieldM12.addPropertyChangeListener("value", this);
			jFormattedTextFieldM12.setInputVerifier(new FloatNumberVerifier());
			//jFormattedTextFieldM12.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);	
			jFormattedTextFieldM12.setColumns(5);
			jPanelM12.add(jLabelM12, 			  BorderLayout.WEST);
			jPanelM12.add(jFormattedTextFieldM12, BorderLayout.CENTER);	
			jFormattedTextFieldM12.setEnabled(true);
		}
		return jPanelM12;
	}
	//--------------------------------------------------------------------------------------------
	/**
	 * This method initializes the Option: Nearest Neighbor	
	 * 	
	 * @return javax.swing.JRadioButtonMenuItem	
	 */
	private  JRadioButtonMenuItem getJRadioButtonMenuButtNN() {
		if (buttNN == null) {
			buttNN  = new JRadioButtonMenuItem();
			buttNN .setText("Near. Neighbor");
			buttNN .setToolTipText("uses Nearest Neighbor resampling for rotation");
			buttNN .addActionListener(this);
			buttNN.setActionCommand("parameter");
		}
		return buttNN;
	}
	/**
	 * This method initializes the Option: Bilinear interpolation
	 * 	
	 * @return javax.swing.JRadioButtonMenuItem	
	 */
	private  JRadioButtonMenuItem getJRadioButtonMenuButtBL() {
		//if (buttBL == null) {
			buttBL  = new JRadioButtonMenuItem();
			buttBL .setText("Bilinear");
			buttBL .setToolTipText("uses Bilinear interpolation for rotation");
			buttBL .addActionListener(this);
			buttBL.setActionCommand("parameter");
		//}
		return buttBL;
	}
	/**
	 * This method initializes the Option: Bicubic interpolation	
	 * 	
	 * @return javax.swing.JRadioButtonMenuItem	
	 */
	private  JRadioButtonMenuItem getJRadioButtonMenuButtBC() {
		//if (buttBC == null) {
			buttBC  = new JRadioButtonMenuItem();
			buttBC .setText("Bicubic");
			buttBC .setToolTipText("uses Bicubic interpoolation for rotation");
			buttBC .addActionListener(this);
			buttBC.setActionCommand("parameter");
		//}
		return buttBC;
	}
	/**
	 * This method initializes the Option: Bicubic2 interpolation	
	 * 	
	 * @return javax.swing.JRadioButtonMenuItem	
	 */
	private  JRadioButtonMenuItem getJRadioButtonMenuButtBC2() {
		//if (buttBC2 == null) {
			buttBC2  = new JRadioButtonMenuItem();
			buttBC2 .setText("Bicubic2");
			buttBC2 .setToolTipText("uses Bicubic2 interpolation for rotation");
			buttBC2 .addActionListener(this);
			buttBC2.setActionCommand("parameter");
		//}
		return buttBC2;
	}
	/**
	 * This method initializes the hidden option	
	 * 	
	 * @return javax.swing.JRadioButtonMenuItem	
	 */
	private  JRadioButtonMenuItem getJRadioButtonMenuButtIntPHidden() {
		//if (buttIntPHidden == null) {
			buttIntPHidden  = new JRadioButtonMenuItem();
			buttIntPHidden .setText("Hidden");
			buttIntPHidden.setVisible(false);
		//}
		return buttIntPHidden;
	}
	/**
	 * This method initializes jJToolBarBar	
	 * 	
	 * @return javax.swing.JToolBar	
	 */
	private   JToolBar getJToolBarIntP() {
//		if (jToolBarIntP== null) {
			jToolBarIntP = new JToolBar("Options");
			jToolBarIntP.setOrientation(1); // 0 Horizontal 1 Vertical orientation
			jToolBarIntP.add(getJRadioButtonMenuButtNN());
			jToolBarIntP.add(getJRadioButtonMenuButtBL());
			jToolBarIntP.add(getJRadioButtonMenuButtBC());
			jToolBarIntP.add(getJRadioButtonMenuButtBC2());
			jToolBarIntP.add(getJRadioButtonMenuButtIntPHidden());
			//jToolBarIntP.addSeparator();
			this.setButtonGroupIntP();	//Gruppieren der JRadioButtons
//		}
		return jToolBarIntP;
	}
	private  void setButtonGroupIntP() {
		//if (ButtonGroup buttGroup == null) {
			buttGroupIntP = new ButtonGroup();
			buttGroupIntP.add(buttNN);
			buttGroupIntP.add(buttBL);
			buttGroupIntP.add(buttBC);
			buttGroupIntP.add(buttBC2);
			buttGroupIntP.add(buttIntPHidden);
	}

	//--------------------------------------------------------------------------------------------
	public void actionPerformed(ActionEvent e) {
		//System.out.println("IqmAffineGUI: event e: " +e.getActionCommand());
		if ("reset".equals(e.getActionCommand())) {
			ParameterBlockJAI pb = new ParameterBlockJAI("IqmAffine".toLowerCase());
			IqmTools.setCurrParameterBlockJAI(pb);
			this.setParameterBlock(pb);
			this.setParameterValues();
			//this.updateIqmOperatorGUI();  //if necessary here or some lines above
			this.reset();
		}
		if ("parameter".equals(e.getActionCommand())) {
			this.setParameterBlock();
			//this.updateIqmOperatorGUI();  //if necessary here or some lines above
		}
	
		//preview if selected
		if (this.isAutoPreviewSelected()){
			this.showPreview();
		}

	}
	//-----------------------------------------------------------------------------------------------

	@Override
	public void propertyChange(PropertyChangeEvent e) {
		if (jFormattedTextFieldM00 == e.getSource()) {
		}
		if (jFormattedTextFieldM10  == e.getSource()) {
		}
		if (jFormattedTextFieldM01  == e.getSource()) {
		}
		if (jFormattedTextFieldM11  == e.getSource()) {
		}
		if (jFormattedTextFieldM02  == e.getSource()) {
		}
		if (jFormattedTextFieldM12  == e.getSource()) {
		}
		this.setParameterBlock();
		//this.updateIqmOperatorGUI();  //if necessary here or some lines above
		
		//preview if selected
		if (this.isAutoPreviewSelected()){
			this.showPreview();
		}
	}

	//-------------------------------------------------------------------------------------------------
	public static void main() {

		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				IqmAffineGUI gui = new IqmAffineGUI();
				gui.createIqmOperatorGUI();

			}
		});
	}




	
}//END
